﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Empresa.aspx.cs" Inherits="entgp.Empresa.Empresa" %>

<%--<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>--%>
<%@ Register Src="wucEmpresa.ascx" TagName="wucEmpresa" TagPrefix="uc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>

 <form id="form1" runat="server">
 
 <ext:ResourceManager ID="ResourceManager1" runat="server" DirectMethodNamespace="RolAjax" Theme="Slate">
    </ext:ResourceManager>
        <ext:Store ID="StoreEstado" runat="server">
            <Reader>
                <ext:ArrayReader>
                    <Fields>
                        <ext:RecordField Name="value" />
                        <ext:RecordField Name="name" />
                    </Fields>
                </ext:ArrayReader>
            </Reader>            
    </ext:Store>   
   
    <script type="text/javascript" language="javascript">
        var EliminarRegistro = function () {
            Ext.MessageBox.show({
                title: "Eliminar Documento",
                msg: "Esta seguro de eliminar el item seleccionado?",
                buttons: Ext.MessageBox.OKCANCEL,
                fn: ConfirmDelDoc,
                icon: Ext.MessageBox.WARNING
            });
        }

        function ConfirmDelDoc(btn)
        {
            if(btn=='ok')
            {
                <%= GridPanelEmpresa.ClientID %>.deleteSelected();
             }
        };

        var prepareToolbar = function (grid, toolbar, rowIndex, record)
        {
             try{
              var opc =hidEstado.getValue();
              
              if(opc=='0')  
              {
                    toolbar.items.itemAt(0).hide();
                    toolbar.items.itemAt(1).hide();
                    toolbar.items.itemAt(2).show();
               }
               else
               {
                    toolbar.items.itemAt(0).show();
                    toolbar.items.itemAt(2).hide();
                    toolbar.items.itemAt(1).show();
  
               }
            }catch(ie)
            {
              alert(ie);
            } 
       
             
        };


    </script>
    <ext:Hidden ID="hidIdRol" runat="server">
    </ext:Hidden>
   
    <ext:Store runat="server" ID="StoreEmpresa"  OnRefreshData="StoreRefresh" AutoLoad="false">
        <Reader>
            <ext:JsonReader IDProperty="Id">
                <Fields>
                    <ext:RecordField Name="Id" />
                    <ext:RecordField Name="Nombre" />
                    <ext:RecordField Name="Descripcion" />
                    <ext:RecordField Name="Codigo" />
                </Fields>
             </ext:JsonReader>
        </Reader>
        <Proxy>
            <ext:PageProxy></ext:PageProxy>
        </Proxy>
        <BaseParams>
			<ext:Parameter Name="txtDescripcion_bprm" Value="#{txtDescripcion}.getValue()"   Mode="Raw" />
			<ext:Parameter Name="txtNombre_bprm" Value="#{txtNombre}.getValue()"   Mode="Raw" />	
            <ext:Parameter Name="cbxEstado_bprm" Value="#{cbxEstado}.getValue()"   Mode="Raw" />		
		</BaseParams>
    </ext:Store>
    
    <ext:Panel ID="Panel1" BodyStyle="padding:15px;background-color:#E7E4DD;" runat="server"  
        AutoHeight="true">
        <Items>
            <ext:Panel ID="Panel2" runat="server" BodyStyle="background-color:Transparent;" ButtonAlign="Center" Layout="Column" Height="90">
                <Items>
                       
                            <ext:Panel ID="Panel3" runat="server"   ColumnWidth=".33" Layout="Form" Border="false" Header="false" BodyStyle="padding:10px;background-color:Transparent;">
                                <Items>
                                      <ext:TextField FieldLabel="Nombre" ID="txtNombre" runat="server" AnchorHorizontal="95%"  />
                                </Items>
                            </ext:Panel>
                            <ext:Panel ID="Panel4" runat="server"  ColumnWidth=".33" Layout="Form"  Border="false" BodyStyle="padding:10px;background-color:Transparent;">
                                <Items>
                                     <ext:TextField FieldLabel="Descripción" ID="txtDescripcion" runat="server" AnchorHorizontal="95%" />  
                                </Items>
                            </ext:Panel>
                                               
                            <ext:Panel ID="Panel5" runat="server"   ColumnWidth=".33" Layout="Form"  Border="false" BodyStyle="padding:10px;background-color:Transparent;">
                                <Items>
                                   <ext:ComboBox  ID="cbxEstado"   AnchorHorizontal="95%"  FieldLabel="Estado"  runat="server"  StoreID="StoreEstado"  Width="250"   Editable="false"  DisplayField="name"
                                                    ValueField="value"   EmptyText="Seleccione Estado">
                                         <Listeners> </Listeners>  
                                  </ext:ComboBox>
                               </Items>
                            </ext:Panel>
                         
                </Items>
                <Buttons>
                    <ext:Button runat="server" ID="btnBuscar" Text="Buscar" Icon="Find">
                        <%--
                        <DirectEvents>
                            <Click OnEvent="btnBuscar_Click">
                                <EventMask ShowMask="true" />
                            </Click>
                        </DirectEvents>
                        --%>
                        <Listeners>
                          <Click Handler="#{StoreEmpresa}.load();" />
                        </Listeners>
                       
                    </ext:Button>
                </Buttons>
            </ext:Panel>
        </Items>
    </ext:Panel>
    <ext:GridPanel ID="GridPanelEmpresa" runat="server" StoreID="StoreEmpresa" StripeRows="true"
        AutoWidth="true" AutoHeight="true" Title="Listado de Empresas">
        <TopBar>
            <ext:Toolbar runat="server">
                <Items>
                    <ext:Button runat="server" ID="btnNuevo" Text="Nuevo" Icon="Add">
                        <DirectEvents>
                            <Click OnEvent="btnNuevo_Click">
                            <ExtraParams>
                            <ext:Parameter Name="Operacion" Value="Nuevo" Mode="Value"></ext:Parameter>
                            </ExtraParams>
                            </Click>
                        </DirectEvents>
                    </ext:Button>
                </Items>
            </ext:Toolbar>
        </TopBar>
        <ColumnModel ID="ColumnModel1" runat="server">
            <Columns>
                <ext:CommandColumn  Width="70">
                    <Commands>
                        <ext:GridCommand CommandName="Editar"  Icon="ApplicationEdit" ToolTip-Text="Editar datos del rol">
                        </ext:GridCommand>
                        <ext:GridCommand CommandName="Eliminar"  Icon="PageDelete" ToolTip-Text="Eliminar item">
                        </ext:GridCommand>
                         <ext:GridCommand CommandName="Activar" Text="Activar" Icon="ArrowRefresh" ToolTip-Text="Activar item">
                         
                        </ext:GridCommand>
                    </Commands>
                    <PrepareToolbar Fn="prepareToolbar"/>
                </ext:CommandColumn>

                <ext:Column ColumnID="Nombre" Header="Nombre" Width="180" Sortable="true"
                    DataIndex="Nombre" />
                <ext:Column Header="Descrición" Sortable="true" DataIndex="Descripcion"  Width="200"/>
               
            </Columns>
        </ColumnModel>
        <DirectEvents>
            <Command OnEvent="command_Click">
                <ExtraParams>
                    <ext:Parameter Name="Operacion" Value="command" Mode="Raw" Encode="False" />
                    <ext:Parameter Name="Id" Value="record.data.Id" Mode="Raw" />
                 </ExtraParams>
            </Command>
        </DirectEvents>
        <SelectionModel>
            <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true">
            </ext:RowSelectionModel>
        </SelectionModel>
    </ext:GridPanel>
    <uc1:wucEmpresa runat="server" ID="wucEmpresa1" />
    <!--
        <ext:Hidden runat="server" ID="hidEstado" >
        </ext:Hidden>
     -->


    </form>
    
</body>
</html>
